import { defHttp } from '/@/utils/http/axios';
import {
  CreateRoleParam,
  RoleListGetResultModel,
  RolePageListGetResultModel,
  RolePageParams,
  RoleParams,
  UpdateRoleParam,
} from './model/roleModel';

enum Api {
  CreateRole = '/system/role/createRole',
  UpdateRole = '/system/role/updateRole',
  DeleteRole = '/system/role/deleteRole',
  SetRoleStatus = '/system/role/setRoleStatus',
  GetAllRoleList = '/system/role/getAllRoleList',
  RolePageList = '/system/role/getRoleListByPage',
}

export const createRole = (params?: CreateRoleParam) =>
  defHttp.post({ url: Api.CreateRole, params: params });

export const updateRole = (params?: UpdateRoleParam) =>
  defHttp.post({ url: Api.UpdateRole, params: params });

export const deleteRole = (roleId: number) =>
  defHttp.get({ url: Api.DeleteRole, params: { roleId } });

export const setRoleStatus = (id: number, status: number) =>
  defHttp.get({ url: Api.SetRoleStatus, params: { id, status } });

export const getAllRoleList = (params?: RoleParams) =>
  defHttp.get<RoleListGetResultModel>({ url: Api.GetAllRoleList, params });

export const getRoleListByPage = (params?: RolePageParams) =>
  defHttp.get<RolePageListGetResultModel>({ url: Api.RolePageList, params });
